﻿/*

  The contents of this file are subject to the Mozilla Public License Version
  1.1 (the "License"); you may not use this file except in compliance with
  the License. You may obtain a copy of the License at 
  
           http://www.mozilla.org/MPL/ 
  
  Software distributed under the License is distributed on an "AS IS" basis,
  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  for the specific language governing rights and limitations under the License. 
  
  The Original Code is LunAS Library.
  
  The Initial Developer of the Original Code is
  ALCARAZ Marc (aka eKameleon)  <ekameleon@gmail.com>.
  Portions created by the Initial Developer are Copyright (C) 2004-2010
  the Initial Developer. All Rights Reserved.
  
  Contributor(s) :
  Nicolas Surian (aka NairuS) <nicolas.surian@gmail.com> 
*/

package examples 
{
    import lunas.display.button.BackgroundButton;
    import lunas.display.button.BackgroundButtonStyle;
    
    import flash.display.Sprite;
    import flash.display.StageScaleMode;
    import flash.events.MouseEvent;
    import flash.filters.DropShadowFilter;
    
    public class ExampleBackgroundButton extends Sprite 
    {
        public function ExampleBackgroundButton()
        {
            //////////
            
            stage.scaleMode = StageScaleMode.NO_SCALE ;
            
            //////////
            
            var groupName:String = "background_button_group" ;
            
            bt1           = new BackgroundButton() ;
            bt1.x         = 25 ;
            bt1.y         = 50 ;
            bt1.groupName = groupName ;
            bt1.toggle    = true ;
            
            addChild(bt1) ;
            
            //////////
            
            bt2           = new BackgroundButton() ;
            bt2.x         = 25 ;
            bt2.y         = 80 ;
            bt2.groupName = groupName ;
            bt2.toggle    = true ;
            
            addChild(bt2) ;
            
            //////////
            
            var init:Object = 
            { 
                themeFilters : [ new DropShadowFilter(4,45,0,0.7) ] 
            } ;
            
            bt3           = new BackgroundButton() ;
            bt3.x         =  25 ;
            bt3.y         = 110 ;
            bt3.groupName = groupName ;
            bt3.toggle    = true ;
            bt3.style     = new BackgroundButtonStyle( init ) ;
            
            addChild(bt3) ;
            
            //////////
            
            bt1.addEventListener( MouseEvent.CLICK , click ) ;
            bt2.addEventListener( MouseEvent.CLICK , click ) ;
            bt3.addEventListener( MouseEvent.CLICK , click ) ;
            
            ////////// Test singleton style by default
            
            bt1.setStyle( "topLeftRadius" , 4 ) ; 
            bt2.setStyle( "bottomLeftRadius" , 4 ) ;
            
            // Note: the style is a singleton by default in all default components
        }
        
        public var bt1:BackgroundButton ;
        public var bt2:BackgroundButton ;
        public var bt3:BackgroundButton ;
        
        public function click( e:MouseEvent ):void
        {
            trace( e ) ;
        }
    }
}
